﻿namespace A80深刻理解类和对象
{
    //深刻理解 c#    clr.via
    class Program
    {
        static void Main1(string[] args)
        {
            MyClass mc = new MyClass(5);
            MyClass mc1 = new MyClass(6);
            Person[] array = new Person[10];
        }
    }
    class MyClass
    {
        public int x;
        public MyClass(int x)
        {
            this.x = x;
        }
    }

    //人的父亲还是人类型
    class Person
    {
        public Person father;
    }

    //练习 定义一个学生类  创建3个学生对象  求三个学生的平均年龄

    class Test
    {
        static void Main(string[] args)
        {
            Student s1 = new Student(20);
            Student s2 = new Student(22);
            Student s3 = new Student(26);

            Student[] array = new Student[] { s1, s2, s3 };

            int sum = 0;//年龄和
            for (int i = 0; i < array.Length; i++)
            {
                sum += array[i].age;
            }
            System.Console.WriteLine("平均年龄:{0}",sum/(float)array.Length);
        }
    }

    class Student
    {
        public int age;
        public Student(int age)
        {
            this.age = age;
        }
    }
}
